'use strict';

const Controller = require('egg').Controller;

const { successRes } = require('../../res/index');

/**
 * @Controller 用户信息
 */

class IndexController extends Controller {
    /**
     * @summary 全部用户
     * @router get /userAll
     * @response 200 baseResponse
     */
    async AllUser() {
        const { ctx } = this;
        let data = await ctx.service.user.index.getAllUser()
        ctx.body = successRes(data)
    };
    /**
     * @summary 根据id查询用户
     * @router get /user
     * @request query integer *id 用户ID 
     * @response 200 testResponse
     */
    async findUser() {
        const { ctx } = this;
        const id = ctx.query.id;
        // const id = ctx.params.id
        let data = await ctx.service.user.index.getFindUserId(id);
        ctx.body = successRes(data)
    };
    /**
     * @summary 创建用户
     * @router post /createUser
     * @request body userData description-userData
     * @response 200 testResponse
     */
    async createUser() {
        const { ctx } = this;
        const obj = ctx.request.body
        ctx.body = await {
            message: 'swagger is OK!!! and query is:',
            data: obj
        }
    };
}

module.exports = IndexController;